<template>
  <div class="routeTitle">
    <div class="backGo" @click="goBack">{{ pageName }}</div>
    <slot/>
  </div>
</template>

<script>
export default {
  name: "",
  props: {
    backUrl: {
      type: String,
      default: ''
    }
  },
  components: {},
  data() {
    return {
        pageName: ''
    };
  },
  computed: {},
  watch: {
    $route: {
      handler(val) {
        this.pageName= val.meta.title
      },
      deep: true,
      immediate: true,
    },
  },
  created() {},
  mounted() {
  },
  methods: {
    goBack() {
      if(this.backUrl) {
        this.$router.push(this.backUrl)
      } else {
        history.go(-1)
      }
    }
  },
};
</script>

<style scoped lang="less">
    .routeTitle{
        text-align: right;
        margin-bottom: 5px;
        overflow: hidden;
        .backGo{
            float: left;
            cursor: pointer;
            color: rgba(0, 0, 0, 0.85);
            font-weight: bold;
            font-size: 18px;
            height: 32px;
            line-height: 32px;
            &::before{
              content: '';
              display: inline-block;
              width: 16px;
              height: 16px;
              background-image: url('~@/assets/image/back.png');
              background-size: cover;
              margin-right: 5px;
              vertical-align: middle;
            }
        }
    }
</style>
